package com.siyu.strateegy;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Author: siyu
 * @CreateTime: 2024-10-07
 * @Version: 1.0
 */
public class PreferentialFactory {
    private static Map<String,Preferential> PREFERENTIALS = new HashMap<>();

    static {
        PREFERENTIALS.put(PreferentialKey.COUPON,new CouponPreferential());
        PREFERENTIALS.put(PreferentialKey.GROUP,new GroupPreferential());
        PREFERENTIALS.put(PreferentialKey.CASHBACK,new CashBackPreferential());

    }
    private static final Preferential EMPTY= new EmptyPreferential();
    private PreferentialFactory(){}

    public static Preferential getPreferential(String preferentialKey){
        Preferential preferential = PREFERENTIALS.get(preferentialKey);
        return preferential == null ? EMPTY : preferential;
    }

    interface PreferentialKey{
        String COUPON = "COUPON";
        String GROUP = "GROUP";
        String CASHBACK = "CASHBACK";

    }

    public static Set<String> getPreferentialKeys(){
        return PREFERENTIALS.keySet();
    }
}
